package com.dogsong.liteflow.editor.component;

import com.dogsong.liteflow.editor.slot.request.SwitchData;
import com.dogsong.liteflow.editor.slot.SwitchContext;
import com.yomahub.liteflow.core.NodeSwitchComponent;
import org.springframework.stereotype.Component;

/**
 * IfBuy2Cmp
 *
 * @author <a href="mailto:dogsong99@163.com">dosong</a>
 * @since 2024/4/23
 */
@Component("switchCmp")
public class SwitchCmp extends NodeSwitchComponent {

    @Override
    public String processSwitch() throws Exception {
        SwitchContext context = this.getContextBean(SwitchContext.class);
        SwitchData data = this.getRequestData();
        return context.getSwitchValue(this.getTag()) == null ? (String) data.getSwitchValue(this.getTag()) :
                (String) context.getSwitchValue(this.getTag());
    }

}
